package com.ssm.auth.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.ssm.auth.infra.basic.entity.AuthUser;
import com.ssm.auth.infra.basic.mapper.AuthUserDao;
import com.ssm.auth.infra.basic.service.AuthUserService;
import lombok.extern.java.Log;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户信息表(AuthUser)表服务实现类
 *
 * @author makejava
 * @since 2024-12-13 10:07:40
 */
@Service("authUserService")
@Log4j2
public class AuthUserServiceImpl implements AuthUserService {
    @Resource
    private AuthUserDao authUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AuthUser queryById(Long id) {
        return this.authUserDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param authUser 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(AuthUser authUser) {
        if(log.isInfoEnabled()) {
            log.info("authUser.register.authUser:{}", JSON.toJSONString(authUser));
        }
        return this.authUserDao.insert(authUser);
    }

    /**
     * 修改数据
     *
     * @param authUser 实例对象
     * @return 实例对象
     */
    @Override
    public int update(AuthUser authUser) {
        if(log.isInfoEnabled()) {
            log.info("AuthUserDomainService.update.authUser:{}", JSON.toJSONString(authUser));
        }
        return this.authUserDao.update(authUser);
    }

    /**
     * 查询用户
     * @param authUser
     * @return
     */
    @Override
    public List<AuthUser> queryByCondition(AuthUser authUser) {
        List<AuthUser> authUsers = authUserDao.queryByCondition(authUser);
        if(log.isInfoEnabled()) {
            log.info("AuthUserDomainService.queryByCondition.authUsers:{}", JSON.toJSONString(authUsers));
        }
        return authUsers;
    }

    /**
     * 根据用户名称修改
     * @param authUser
     * @return
     */
    @Override
    public int updateByUserName(AuthUser authUser) {
        if(log.isInfoEnabled()) {
            log.info("AuthUserDomainService.updateByUserName.authUser:{}", JSON.toJSONString(authUser));
        }
        return this.authUserDao.updateByUserName(authUser);
    }

    @Override
    public List<AuthUser> listUserInfoByIds(List<String> userNameList) {
        return authUserDao.listUserInfoByIds(userNameList);
    }

}
